<?php
include '../Classes/userHandler.php';
include '../Classes/db.php';

$x=new DbConnect();
$con=$x->getConnection();

$level=$_GET['level'];
$emp=$_GET['empno'];
$username=addslashes($_GET['uname']);
$password=md5($_GET['pword']);
$status="Active";
$len=strlen($emp);

//checkin Registration number already in the login table

$resultlog=mysql_query("select u_name from login where emp_reg='$emp'",$con);
$num=mysql_fetch_array($resultlog);

	if($num==0)
	{
		if($len=="4")
		{
			if(!($level=="Parent"))
					{
					$users=new UserHandler();
					$users->setConnect($con);
					$user=$users->userAdd($emp,$username,$password,$level,$status);
					echo $user;
					}
			else
					{
					echo"Invalid Privileges for Employee"; 
					}
		}
		elseif($len=="5") 
		{
				if(!($level=="User"||$level=="Admin"))
						{
						$users=new UserHandler();
						$users->setConnect($con);
						$user=$users->userAdd($emp,$username,$password,$level,$status);
						echo $user;
						}
				else
						{
     					echo"Invalid Privileges for Student"; 
						}
		}
		else
		{
				echo "Invalid Input No";
		}

	mysql_close($con);
} 
else
{
	echo"Reg_emp No have a profile";
}
?>